﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Windows;
using System.Windows.Controls;
using System.Windows.Data;
using System.Windows.Documents;
using System.Windows.Input;
using System.Windows.Media;
using System.Windows.Media.Imaging;
using System.Windows.Shapes;

namespace Client
{
    /// <summary>
    /// Interaction logic for AccountInfo.xaml
    /// </summary>
    public partial class AccountInfo : Window
    {
        System.Windows.Threading.DispatcherTimer dispatcherTimer;

        public AccountInfo()
        {
            InitializeComponent();
        }


        // USER MANAGEMENT

        private void btnCancel_Click(object sender, RoutedEventArgs e)
        {
            tbxName.Text = "";
            tbxPass.Text = "";
            tbxEmail.Text = "";
            tbxPhone.Text = "";
            tbxFirstName.Text = "";
            tbxLastName.Text = "";
            formController.ShowForm(typeof(saunaMain));
        }

        private void btnUpdate_Click(object sender, RoutedEventArgs e)
        {
            formController.UpdateProfile(tbxName.Text, tbxFirstName.Text, tbxLastName.Text, tbxPass.Text, tbxEmail.Text, tbxPhone.Text);
        }


        // FORM MANAGEMENT

        private void dispatcherTimer_Tick(object sender, EventArgs e)
        {
            if (formController.newProtocol == true)
            {
                switch (formController.receivedProtocol)
                {

                    #region Update Profile

                    case "UP":
                        {
                            formController.ShowForm(typeof(saunaMain));
                        }
                        break;

                    #endregion

                    default:

                        break;
                }

                formController.newProtocol = false;
            }
        }

        private void Window_Loaded(object sender, RoutedEventArgs e)
        {
            dispatcherTimer = new System.Windows.Threading.DispatcherTimer();

            dispatcherTimer.Tick += new EventHandler(dispatcherTimer_Tick);

            dispatcherTimer.Interval = new TimeSpan(0, 0, 1);

            dispatcherTimer.Start();
        }

    }
}
